  <?php echo $header;?>
  <script type="text/javascript"><!--
            function filter() {
                    url = 'index.php?route=Mart_Crm/month_report&token=<?php echo $token; ?>';

                    var filter_group = $('select[name=\'filter_group\']').attr('value');

                    if (filter_group) {
                            url += '&filter_group=' + encodeURIComponent(filter_group);
                    }

                    location = url;
            }
                            //--></script> 
  <script type="text/javascript"><!--
            $(document).ready(function() {
                $('#date-start').datepicker({dateFormat: 'yy-mm-dd'});

                $('#date-end').datepicker({dateFormat: 'yy-mm-dd'});
            });
            //--></script> 
  <?php
    
    $str_data1 = "[['Task', 'Doanh thu theo tháng']";
    $str_data = "";
    $name = "";
    $filter_group = "";
    foreach ($rows as $result)  
    {
            $str_data = $str_data.", ['".$result['name']."', ".$result['amount']."]";
            $filter_group = $result['filter_group'];
    }
    $name = $str_data1.$str_data."]";
?>
<style type="text/css">
        .table
        {
            border-collapse: collapse;
                border: 1px solid #00CCCC;
        }

        .td
        {
            border-collapse: collapse;
           border: 1px solid #00CCCC;
        }
</style>
  <div id="content">
      <div class="box">
          <div class="heading">
              <h1 align="center"><img src="view/image/report.png" alt="" /><?php echo $heading_title; ?></h1>
              <div class="buttons">
                  <a align="center" onclick="window.open('<?php echo $print; ?>', '_blank')" class="button"><?php echo $button_export_pdf; ?></a>
              </div>
               <div class="buttons">
                  <a align="center" onclick="window.open('<?php echo $export_excel; ?>', '_blank')" class="button"><?php echo $button_export_excel; ?></a>
              </div>
          </div>
          <div class="content">
              
              <table class="form">
        <tr>
          <td><?php echo $entry_group; ?>
            <select name="filter_group">
              <?php foreach ($groups as $groups) { ?>
              <?php if ($groups['value'] == $filter_group) { ?>
              <option value="<?php echo $groups['value']; ?>" selected="selected"><?php echo $groups['text']; ?></option>
              <?php } else { ?>
              <option value="<?php echo $groups['value']; ?>"><?php echo $groups['text']; ?></option>
              <?php } ?>
              <?php } ?>
            </select></td>
         
          <td style="text-align: right;"><a onclick="filter();" class="button"><?php echo $button_display; ?></a></td>
        </tr>
      </table>
              <?php if ($rows) { ?>
              <div align=center class="reportChartContainer"> 
                <script type="text/javascript" src="https://www.google.com/jsapi"></script>   
                <script type="text/javascript">
                google.load("visualization", "1", {packages:["corechart"]});
                google.setOnLoadCallback(drawChart);
                function drawChart() {
                    var data = google.visualization.arrayToDataTable(<?php echo $name?>);

                    var options = {title: 'Doanh thu theo tháng ',
                    hAxis: {title: 'Tháng - năm <?php echo $filter_group; ?>', titleTextStyle: {color: 'red'}}
                    };

                    var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
                    chart.draw(data, options);
                }
                </script>
               </div>
                <center>    
               <div align=center id="chart_div" style="width: 900px; height: 500px;"></div>
                </center>
               <table cellpadding='0' cellspacing='0' width='100%' border='0' class="table">

                    <tr bgcolor="Gainsboro" height='20'>
                        <td class="td"><p align="center"><b><?php echo $STT; ?></b>
                        </td>
                        <td class="td"><p align="center"><b><?php echo $month; ?></b>
                        </td>

                        <td class="td"><p align="center"><b><?php echo $Doanhthu; ?></b>
                        </td>
                    </tr>
                    
                    
                    <?php
                        $i = 0; 

                        foreach ($rows as $result) {
                        $i=$i + 1;
                        echo " <tr height='20'>";
                        echo "<td class='td'><p align='center'><b>".$i."</b>";
                        echo "</td>";
                        echo "<td class='td'><p align='center'>
                            <b>".$result['name']."</b>";
                        echo "</td>";
                        echo "<td class='td'><p align='center'><b>".$result['amount']."</b>"; 
                        echo "</td>";
                       } 
                    ?>
               </table>
                    
                    <?php } else { ?>
          <tr>
            <td class="center" colspan="6"><?php echo $text_no_results; ?></td>
          </tr>
          <?php } ?>
          </div>
      </div>
  </div>


  <?php echo $footer;?>